// id自增,id为5feb61565eaa993c00325397775132e3的数据 手动实现了id自增
const cloud = require('wx-server-sdk')

cloud.init()
const db = cloud.database();
const _ = db.command
exports.main = async(event, context) => {
  try {
    let id = await db.collection('count').doc('5feb61565eaa993c00325397775132e3').get()
    console.log('id:', id)
    await db.collection('count').doc('5feb61565eaa993c00325397775132e3').update({data: {id: _.inc(1)}})
    return id.data.id+1
  } catch (err) {
    console.log(err)
    return err
  }
}